import request from '@/utils/request.js'

/**
 * 添加计划
 * @param {string} planName 计划名称
 * @param {string} planType 计划类型
 * @param {string | undefined} planTime 计划时间，默认为undefined
 * @returns 返回一个Promise对象，请求成功后解析为响应数据
 */
export const addPlan = (planName, planType, planTime = undefined) => {
	return request(`biz/plan`, {
		method: 'post',
		data: {
			planName,
			planType,
			planTime
		}
	})
}

/**
 * 删除计划
 * @param {number} planId 计划ID
 * @returns 返回一个Promise对象，请求成功后解析为响应数据
 */
export const delPlan = (planId) => {
	return request(`biz/plan/${planId}`, {
		method: 'delete',
		backAll: true
	})
}

/**
 * 获取任务
 * @param {string} planType 计划类型
 * @param {string | undefined} createTime 创建时间，默认为undefined
 * @returns 返回一个Promise对象，请求成功后解析为响应数据
 */
export const getTask = (planType, planTime = undefined) => {
	return request(`biz/plan/list`, {
		method: 'get',
		data: {
			planTime,
			planType
		},
		backAll: true
	})
}